package planit;

import planit.controller.ControllerFactory;
import planit.controller.ControllerFactory.ControllerType;
import planit.controller.impl.AddPersonToEventController;
import planit.controller.impl.AddPersonToGroupController;
import planit.controller.impl.CheckoutController;
import planit.controller.impl.CommitChangesController;
import planit.controller.impl.CreateEventController;
import planit.controller.impl.CreateGroupController;
import planit.controller.impl.CreatePersonController;
import planit.controller.impl.DeleteEventController;
import planit.controller.impl.DeleteGroupController;
import planit.controller.impl.DeletePersonController;
import planit.controller.impl.EditEventController;
import planit.controller.impl.EditGroupController;
import planit.controller.impl.EditPersonController;
import planit.controller.impl.RemovePersonFromEventController;
import planit.controller.impl.RemovePersonFromGroupController;
import planit.model.Model;
import planit.view.View;

public class Main {
	private static Model model;
	private static View view;

	/**
	 * The main method that starts the application
	 * 
	 * @param args
	 *          
	 */
	public static void main(String[] args) {

		model = new Model();
		ControllerFactory.setModel(model);
		seedControllers();
		view = View.getInstance();
		view.setModel(model);
		model.getSchedule().addObserver(view);
		view.run();
	}
	
	private static void seedControllers() {
		ControllerFactory.seedController(ControllerType.CREATE_EVENT, new CreateEventController(model));
		ControllerFactory.seedController(ControllerType.CREATE_PERSON, new CreatePersonController(model));
		ControllerFactory.seedController(ControllerType.CREATE_GROUP, new CreateGroupController(model));

		ControllerFactory.seedController(ControllerType.EDIT_EVENT, new EditEventController(model));
		ControllerFactory.seedController(ControllerType.EDIT_PERSON, new EditPersonController(model));
		ControllerFactory.seedController(ControllerType.EDIT_GROUP, new EditGroupController(model));
		
		ControllerFactory.seedController(ControllerType.DELETE_GROUP, new DeleteGroupController(model));
		ControllerFactory.seedController(ControllerType.DELETE_PERSON, new DeletePersonController(model));
		ControllerFactory.seedController(ControllerType.DELETE_EVENT, new DeleteEventController(model));
		
		ControllerFactory.seedController(ControllerType.ADD_PERSON_TO_EVENT, new AddPersonToEventController(model));
		ControllerFactory.seedController(ControllerType.ADD_PERSON_TO_GROUP, new AddPersonToGroupController(model));
		
		ControllerFactory.seedController(ControllerType.REMOVE_PERSON_FROM_EVENT, new RemovePersonFromEventController(model));
		ControllerFactory.seedController(ControllerType.REMOVE_PERSON_FROM_GROUP, new RemovePersonFromGroupController(model));
		
		ControllerFactory.seedController(ControllerType.CHECKOUT, new CheckoutController(model));
		ControllerFactory.seedController(ControllerType.COMMIT_CHANGES, new CommitChangesController(model));
	}
}
